import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { ResultService } from './result.service';
import { CreateResultDto } from './dto/create-result.dto';
import { UpdateResultDto } from './dto/update-result.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Result } from './entities/result.entity';
import { ResultQueryDto } from './dto/query-result.dto';

@Controller('result')
@ApiTags('Results')
export class ResultController {
  constructor(private readonly resultService: ResultService) { }

  @Post('create')
  @ApiOperation({ summary: 'Create a new result' })
  async create(@Body() createResultDto: CreateResultDto): Promise<Result> {
    return this.resultService.create(createResultDto);
  }

  // @Get()
  // async findAll(@Query() resultQueryDto: ResultQueryDto): Promise<PaginationResult<Result>> {
  //   return this.resultService.findAll(resultQueryDto);
  // }
  @Post('list')
  @ApiOperation({ summary: 'Get a paginated list of results' })
  findAll(@Body() paginationQuery: ResultQueryDto) {
    return this.resultService.findAll(paginationQuery);
  }

  @Get(':id')
  @ApiOperation({ summary: 'Get an result by id' })
  // @Public()
  async findOne(@Param('id') id: string): Promise<Result> {
    return this.resultService.findOne(id);
  }

  @Post('update/:id')
  @ApiOperation({ summary: 'Update an result' })
  async update(@Param('id') id: string, @Body() updateResultDto: UpdateResultDto): Promise<Result> {
    return this.resultService.update(id, updateResultDto);
  }

  @Get('delete/:id')
  @ApiOperation({ summary: 'Delete an result' })
  async remove(@Param('id') id: string): Promise<void> {
    await this.resultService.remove(id);
  }

  @Post('getoptions')
  @ApiOperation({ summary: 'Get results options' })
  async findAllResultsOptions() {
    return this.resultService.findAllResultsOptions();
  }
  // @Delete('/delete/:id')
  // async delete(@Param('id') id: string): Promise<void> {
  //   await this.resultService.delete(id);
  // }
}
